/******************************************************************************
 Copyright (c) 2009-2019 Qualcomm Technologies International, Ltd.
 All Rights Reserved.
 Qualcomm Technologies International, Ltd. Confidential and Proprietary.

 REVISION:      $Revision: #1 $
******************************************************************************/

#include "csr_synergy.h"

#include "csr_bt_profiles.h"
#include "csr_msg_transport.h"
#include "csr_bt_pac_lib.h"

void CsrBtPacMsgTransport(void* msg)
{
    CsrMsgTransport(CSR_BT_PAC_IFACEQUEUE, CSR_BT_PAC_PRIM, msg);
}

void CsrBtPacPullPbReqSend(CsrUcs2String *ucs2name,
                           CsrBtPacSrcType src,
                           CsrUint8 *filter,
                           CsrBtPacFormatType format,
                           CsrUint16 maxLstCnt,
                           CsrUint16 listStartOffset,
                           CsrUint8 resetNewMissedCalls,
                           CsrUint8 *vCardSelector,
                           CsrUint8 vCardSelectorOperator,
                           CsrBool srmpOn)
{
    CsrBtPacPullPbReq *req = CsrPmemZalloc(sizeof(*req));

    req->type = CSR_BT_PAC_PULL_PB_REQ;
    req->ucs2name = ucs2name;
    req->src = src;
    if (filter)
    {
        CsrMemCpy(req->filter, filter, sizeof(req->filter));
    }
    req->format = format;
    req->maxListCnt = maxLstCnt;
    req->listStartOffset = listStartOffset;
    req->srmpOn = srmpOn;
    req->resetNewMissedCalls = resetNewMissedCalls;
    if (vCardSelector)
    {
        CsrMemCpy(req->vCardSelector, vCardSelector, sizeof(req->vCardSelector));
        req->vCardSelectorOperator = vCardSelectorOperator;
    }

    CsrBtPacMsgTransport(req);
}

void CsrBtPacPullVcardListReqSend(CsrUcs2String *ucs2name,
                                  CsrBtPacOrderType order,
                                  CsrUint8 *searchVal,
                                  CsrBtPacSearchAtt searchAtt,
                                  CsrUint16 maxListCnt,
                                  CsrUint16 listStartOffset,
                                  CsrUint8 resetNewMissedCalls,
                                  CsrUint8 *vCardSelector,
                                  CsrUint8 vCardSelectorOperator,
                                  CsrBool srmpOn)
{
    CsrBtPacPullVcardListReq *msg = CsrPmemZalloc(sizeof(CsrBtPacPullVcardListReq));
    msg->type = CSR_BT_PAC_PULL_VCARD_LIST_REQ;
    msg->ucs2name = ucs2name;
    msg->order = order;
    msg->searchVal = searchVal;

    if (searchVal)
    {
        msg->searchValLen = (CsrUint16) (CsrStrLen((char*) searchVal) + 1);
    }

    msg->searchAtt = searchAtt;
    msg->maxListCnt = maxListCnt;
    msg->listStartOffset = listStartOffset;

    msg->resetNewMissedCalls = resetNewMissedCalls;
    if(vCardSelector != NULL)
    {
        CsrMemCpy(msg->vCardSelector,
                  vCardSelector,
                  sizeof(msg->vCardSelector));
        msg->vCardSelectorOperator = vCardSelectorOperator;
    }
    msg->srmpOn = srmpOn;

    CsrBtPacMsgTransport(msg);
}

